export const getAgoAt = (stamptime) => {
  let current_time = Date.parse(new Date()) / 1000
  let diff = current_time - stamptime
  let agoAt = '1分钟前'
  let timePoints = [
    { value: 60 * 60 * 24 * 365, suffix: '年前', max: 2 },
    { value: 60 * 60 * 24 * 30, suffix: '月前', max: 11 },
    { value: 60 * 60 * 24 * 7, suffix: '周前', max: 4 },
    { value: 60 * 60 * 24, suffix: '天前', max: 6 },
    { value: 60 * 60, suffix: '小时前', max: 23 },
    { value: 60 * 10, suffix: '0分钟前', max: 5 }
  ]
  for (let i = 0; i < timePoints.length; i++) {
    let point = timePoints[i]
    let mode = Math.floor(diff / point.value)
    if (mode > 1) {
      agoAt = Math.min(mode, point.max) + point.suffix
      break
    }
  }
  return agoAt
}
